package boolean

import (
	"hi-jvm/instructions/base"
	"hi-jvm/rtda"
)

/*
布尔运算只能操作int和long。
分为按位与（and），按位或（or）， 按位异或（xor）3种
 */

// Boolean AND int
type IAND struct{ base.NoOperandsInstruction }
// Boolean AND long
type LAND struct{ base.NoOperandsInstruction }

func (self *IAND) Execute(frame *rtda.Frame) {
	stack := frame.OperandStack
	v2 := stack.PopInt()
	v1 := stack.PopInt()
	result := v1 & v2
	stack.PushInt(result)
}

func (self *LAND) Execute(frame *rtda.Frame) {
	stack := frame.OperandStack
	v2 := stack.PopLong()
	v1 := stack.PopLong()
	result := v1 & v2
	stack.PushLong(result)
}
